<?php

if (!defined('e107_INIT')) { exit; }

$a_id = array();
$a_name = array();
$a_description = array();
$a_id_cat = array();

if ($sql->db_Select("roll_mini_cards", "*", "name != '-roll_mini_system_name-' ORDER BY id")) {
      while($row = $sql->db_Fetch()) {

          $a_id[] = $row['id'];
          $a_name[] = $row['name'];
          $a_description[] = $row['description'];
          $a_id_cat[] = $row['id_cat'];

      }
}

$count = sizeof($a_id);
$str_size_limit = 250;

$r = rand(0,$count-1);

$text = "
<div id='card_list'>
  <div id='card_list_name'>
    <a href='".e_PLUGIN."roll_mini/roll.php?cat=".$a_id_cat[$r]."&card_id=".$a_id[$r]."'>".$a_name[$r]."</a>
  </div>
  <div id='card_list_description'>
    ".substr($a_description[$r], 0, $str_size_limit)."".(strlen($a_description[$r]) > $str_size_limit ? "...." : "")."
  </div>
</div>
";

$caption = $pref['roll_m_name'];
$ns -> tablerender($caption, $text);

?>